﻿@model string

<script id="user_authentication_template" type="text/x-jquery-tmpl">
	<div class="user_account">
		{{if User}}
			{{tmpl(User) "#authenticated_user_template"}}
		{{else}}
			{{tmpl "#unauthenticated_user_template"}}
		{{/if}}
	</div>
</script>

<script id="authenticated_user_template" type="text/x-jquery-tmpl">
	<span class="user_name">
		${FirstName} ${Surname}
	</span>
	<span class="actions_panel">
		<a id="user_settings_action" class="action first">USTAWIENIA</a>
		<a id="logout_user_action" class="action last">WYLOGUJ</a>
	</span>
</script>

<script id="unauthenticated_user_template" type="text/x-jquery-tmpl">
	<span class="user_name">
		NIEZALOGOWANY
	</span>
</script>

<script type="text/javascript">
	var applicationUserProfileDataSource = new OcenyOpisowe.Client.Data.JsonActionResultDataSource("@Model");

	var applicationInstance = OcenyOpisowe.Client.Application.get_instance();

	var applicationUserProfile = new OcenyOpisowe.Client.Controls.UserProfileControl();

	applicationUserProfile.setUserProfileTemplateIdentifier("user_authentication_template");
	applicationUserProfile.setDataSource(applicationUserProfileDataSource);

	applicationInstance.setUserProfileControl(applicationUserProfile);
	
	applicationUserProfile.dataBind();
</script>